
import { EChartType, ESubAxisChartType } from "@/core/ChartType";
import { FormState } from "../ChartForm";
import { ChartFormItemContext } from "../ChartFormItem";
import { EChartFormItem, EMateDataType, IChartFormItem, IMateData } from "../ChartItemType";
import PieChartFormAbstract from "./PieChartFormAbstract";
export default class AxisChartForm extends PieChartFormAbstract {
    private explorer: ChartFormItemContext;
    private value: ChartFormItemContext;
    // private series: FormState<any>;
    // private legend: FormState<any>;
    // private tooltip: FormState<any>;
    constructor() {
        super();
        this.useFormState("explorer", this.explorer = new ChartFormItemContext({
            label: "统计维度",
            value: "",
            placeHolder: "请选择统计维度的数据",
            // name: "explorer",
            datas: "",
            type: EChartFormItem.Select,
            mateData: {
                type: EMateDataType.String
            }
        }));

        this.useFormState("value", this.value = new ChartFormItemContext({
            label: "数据维度",
            value: "",
            placeHolder: "请选择数据维度的数据",
            // name: "value",
            datas: { type: 'bar' },
            type: EChartFormItem.Select,
            mateData: {
                type: EMateDataType.Number
            }
        }));
        this.useComputed("series", [this.value, this.explorer], () => {
            const valueColumn = this.value.data;
            const explorerColumn = this.explorer.data;
            return {
                name: 'Access From',
                type: 'pie',
                radius: ['40%', '70%'],
                avoidLabelOverlap: false,
                label: {
                    show: false,
                    position: 'center'
                },
                emphasis: {
                    label: {
                        show: true,
                        fontSize: '40',
                        fontWeight: 'bold'
                    }
                },
                labelLine: {
                    show: false
                },
                data: `return $originData.map(row=>{
                    return {
                        value:row['${valueColumn}'],
                        name:row['${explorerColumn}']
                    }
                })`
                // [
                //     { value: 1048, name: 'Search Engine' },
                //     { value: 735, name: 'Direct' },
                //     { value: 580, name: 'Email' },
                //     { value: 484, name: 'Union Ads' },
                //     { value: 300, name: 'Video Ads' }
                // ]
            }
        });
        this.useComputed("legend", [], () => {
            return {
                top: '5%',
                left: 'center'
            };
        });
        this.useComputed("tooltip", [], () => {
            return {
                trigger: 'item'
            }
        });
    }

    chartDataComputed() { }

}